import logging

from config import  BASE_URL


class TenderApi:

    def __init__(self, session):
        self.session = session

    # 获取session对象

    # 投资接口
    def tender(self, id_v, amount_v, depositCertificate_v=-1):
        url = BASE_URL + '/trust/trust/tender'
        info = {"id": id_v, "depositCertificate": depositCertificate_v, "amount": amount_v}
        resp = self.session.post(url, data=info)
        print(f'投资接口的响应数据为 = {resp.json()}')
        logging.info(f'投资接口的响应数据为 = {resp.json()}')
        return resp

    # 第三方投资接口
    def third_tender(self, url, body):
        resp = self.session.post(url, data=body)
        print(f'第三方投资接口的响应数据为 = {resp.text}')
        logging.info(f'第三方投资接口的响应数据为 = {resp.text}')
        return resp
